﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Azure.TableQuery.Core.Interfaces;
using System.IO;

namespace Azure.TableQuery.Core
{
    public class QueryActivator
    {
        public static IQueryContextFactory CreateInstance(string assemblyPath)
        {
            if (!File.Exists(assemblyPath))
            {
                throw new FileNotFoundException(assemblyPath + " not found");
            }

            System.Reflection.Assembly assem = AppDomain.CurrentDomain.Load(
                File.ReadAllBytes(assemblyPath));

            Type queryType = assem.GetType("QueryContextFactory");

            return Activator.CreateInstance(queryType) as IQueryContextFactory;
        }
    }
}
